package Utilidades;

//import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;

public class Limitador extends DefaultStyledDocument {
	
	int caracteres;
	
	public Limitador(int caracteres){
		this.caracteres = caracteres;
	}
	
	public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
	{
		if ((getLength() + str.length())<= caracteres)
			super.insertString(offs, str, a);
		else
			Toolkit.getDefaultToolkit().beep();
			
		
		
	}
	

}
